/**
 * Created by Apple on 2017/6/11.
 */
var ztreeObject;
var setting = {
    check: {
        enable: true,
        chkboxType : { "Y" : "ps", "N" : "p" }
    },
    edit:{
        enable: true,
        showRemoveBtn:false,
        renameTitle:'修改权限'
    },
    view:{
        showLine: true,
        showIcon: true,
        selectedMulti: false,
        fontCss: function(treeId, treeNode){
            //如果是功能权限则标红
            return treeNode.functionType==2? {color:"red"} : {};
        }
    },
    data: {
        simpleData: {
            enable: true,
            idKey:'functionId',
            pIdKey:'parentId',
            rootPid:''
        },
        key:{
            name:'functionName',
            title:'functionName'
        }
    },
    callback: {
        //修改父节点
        beforeDrop:updateParentId,
        //修改权限
        beforeEditName:functionRename
    }
};

/**
 * 初始化权限树
 * @param ztree 权限数据
 */
function showFunctionZtree(ztree){
    ztree = eval('('+ztree+')');
    ztreeObject = $.fn.zTree.init($("#ztreedemo"), setting, ztree);
}

function updateParentId() {
    
}

function functionRename() {
    
}
/**
 * 取消所选
 */
function checkNodeFalse(){
    ztreeObject = $.fn.zTree.getZTreeObj("ztreedemo");
    ztreeObject.checkAllNodes(false);
}